/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.editor.mouseoveraction;

import org.eclipse.draw2d.Locator;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.handles.AbstractHandle;
import org.eclipse.gef.palette.CreationToolEntry;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteEntry;

/**
 * Factory used to create appropriate ActionHandle.
 * 
 * @author dumoulin
 */
public class ActionHandleFactory {

	/**
	 * Create an ActionHandle for the specified toolEntry.
	 * 
	 * @param locator 
	 * @param owner 
	 * @param paletteEntry 
	 * 
	 * @return 
	 */
	public AbstractHandle createActionHandleFor(GraphicalEditPart owner, 
			    PaletteEntry paletteEntry, Locator locator)
	{
		if( paletteEntry instanceof PaletteDrawer)
		{
			return new ActionHandleContainer(owner, (PaletteDrawer)paletteEntry, locator, this);
		}
		else if( paletteEntry instanceof CreationToolEntry )
		{
			return new CreationToolEntryActionHandle(owner, (CreationToolEntry)paletteEntry, locator);
		}
		return null;

	}
}
